package top.hg.tool.modules.car.person;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: skh
 * @Date: 2019/7/29 15:54
 * @Description:
 */
@Repository
@Slf4j
public class LotteryPersonRepository {

    @Autowired
    private LotteryPersonDao lotteryPersonDao;

    public Integer savePerson(LotteryPersonEntity personEntity) {
        lotteryPersonDao.insert(personEntity);
        return personEntity.getId();
    }

    public void updatePersonById(LotteryPersonEntity personEntity) {
        lotteryPersonDao.updateById(personEntity);
    }

    public void deletePersonById(Integer id){
        lotteryPersonDao.deleteById(id);
    }

    public LotteryPersonEntity getPersonById(Integer id) {
        LotteryPersonEntity lotteryPersonEntity = lotteryPersonDao.selectById(id);
        return lotteryPersonEntity;
    }

    public List<LotteryPersonEntity> getPersonListByOpenId(String openId){
        EntityWrapper<LotteryPersonEntity> wrapper = new EntityWrapper<>();
        wrapper.eq("open_id", openId);
        return lotteryPersonDao.selectList(wrapper);
    }
}
